package cn.wolfcode.shop.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;

import cn.wolfcode.shop.domain.SkuPropertyValue;
import cn.wolfcode.shop.mapper.SkuPropertyValueMapper;
import cn.wolfcode.shop.service.ISkuPropertyValueService;

@Service
public class SkuPropertyValueServieImpl implements ISkuPropertyValueService {

	@Autowired
	private SkuPropertyValueMapper propertyValueMapper;

	@Override
	public List<SkuPropertyValue> getPropertyValueList(Long propertyId) {
		return propertyValueMapper.getPropertyValueList(propertyId);
	}

	@Override
	public void saveOrUpdate(List<SkuPropertyValue> propertyValuesList) {
		propertyValuesList.forEach(propertyValues -> {
			if (propertyValues.getId() != null) {
				propertyValueMapper.updateByPrimaryKey(propertyValues);
			} else {
				propertyValueMapper.insert(propertyValues);
			}
		});
	}

	@Override
	public void delete(Long id) {
		propertyValueMapper.deleteByPrimaryKey(id);

	}

}
